package com.qlm.tool;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jfinal.kit.HttpKit;
import com.jfinal.weixin.sdk.kit.PaymentKit;
import com.jfinal.weixin.sdk.utils.JsonUtils;

/**
 * 发送异步请求
 * 
 * @author wangzih
 *
 */
public class HTTPUtil {

	private static Logger logger = LoggerFactory.getLogger(HTTPUtil.class);

	public static void get(String url, Map<String, String> param) {
		new Thread(new Runnable() {
			@Override
			public void run() {
				HttpKit.get(url, param);
				logger.info("发送get请求到,url:"+url+",参数:"+param);
			}
		}).start();
	}
	
	public static void post(String url,Map<String, String> param) {
		new Thread(new Runnable() {
			@Override
			public void run() {
				String json = PaymentKit.packageSign(param, false);
				String post = HttpKit.post(url, json);
				logger.info("发送post请求到,url:"+url+",参数:"+json+",参数返回："+post);
			}
		}).start();
	}
	public static void main(String[] args) {
		Map<String, String> p = new HashMap<String, String>();
		p.put("openid", "op1Oxv92kzXuFoJv3Y_gXcBIVkKE");
		p.put("nick_name", "wz恒");
		p.put("province", "湖北省");
		p.put("city", "十堰市");
		p.put("country", "中国");
		p.put("head_pic", "http://wx.qlogo.cn/mmopen/UB6JyR6zTGFOkPDh6ej5KwRjaoQ31DbI52rz5catD01nPG6JSYL6sudHxPibvkkDAlG6S0p88mkLic6xRQ1T1KsA/0");
		String sign =PaymentKit.createSign(p, "panggeshipin");
		p.put("sign", sign);
		post("http://139.196.51.206/bbc_pangge/ucenter/index.php?ctl=QueryPost&met=tocheckreg&typ=e",p);
		
	}
}
